Load a few packages.
In [12]:
import pandas
pandas.options.display.max_rows = 12
from cameo import models, phenotypic_phase_plane
Load a model E. coli central carbon metabolism.
In [22]:
model = models.bigg.e_coli_core.copy()
Compute the phenotypic phase plane for growth and acetate secretion.
In [14]:
result = phenotypic_phase_plane(model,
variables=[model.reactions.BIOMASS_Ecoli_core_w_GAM],
objective=model.reactions.EX_ac_e)
Look at the result in a tabular view.
In [23]:
result.data_frame
Out[23]:
Plot the phenotypic phase plane.
In [24]:
result.plot()
We can also calculate a three dimensional phenotypic phase plane to compare the influence of aerobic and anaerobic environements.
In [25]:
result_3D = phenotypic_phase_plane(model, variables=[model.reactions.EX_ac_e, model.reactions.EX_o2_e], objective=model.reactions.BIOMASS_Ecoli_core_w_GAM, points=50)
In [26]:
result_3D.data_frame
Out[26]:
Unfortunately, 3D plots are not yet supported out of the box.
In [18]:
result_3D.plot()
So let's quickly write a custom plot (you can use your mouse to rotate the graphic).
In [27]:
%matplotlib notebook
In [28]:
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111, projection='3d')
ax.plot_trisurf(
result_3D.data_frame.EX_ac_e.values,
result_3D.data_frame.EX_o2_e.values,
result_3D.data_frame.objective_upper_bound.values,
cmap=cm.coolwarm, linewidth=0, antialiased=True)
ax.set_xlabel('Acetate [mmol gDW^-1 h^-1]')
ax.set_ylabel('O2 [mmol gDW^-1 h^-1]')
ax.set_zlabel('Biomass [h^-1]')
ax.mouse_init()
# interact(f(fig, ax), angle=(0, 360), elevation=(-100, 100))
In [ ]: